package com.hexiang.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;

@Data
@AllArgsConstructor
@Builder
public class ResultResponse<T extends Serializable> implements Serializable {
    /**
     * 响应的状态码
     */
    private int code;
    /**
     * 响应的响应体
     */
    private T body;
    /**
     * 是否成功
     */
    private boolean succ;
    /**
     * 描述信息
     */
    private String msg;

    public ResultResponse() {

    }

    public static ResultResponse success(String msg, Object data) {
        return new ResultResponse(200, (Serializable) data, true, msg);
    }

    public static ResultResponse error(String msg) {
        return new ResultResponse(500, null, false, msg);
    }
}